package main

import (
	"context"
	"fmt"
	elasticSecher "github.com/olivere/elastic/v7"
	"log"
)

type Person struct {
	Name string `json:"name"`
	Age int `json:"age"`
	Married bool `json:"married"`
}
func main() {
  client,err :=  elasticSecher.NewClient(elasticSecher.SetURL("http://127.0.0.1:9200"))
  if err !=nil{
  	log.Panic(err)
  }
  p1 :=  Person{
	  Name:    "lmh",
	  Age:     18,
	  Married: false,
  }
	put1, err := client.Index().
  	Index("user").
  	BodyJson(p1).
  	Do(context.TODO())
	if err !=nil {
		log.Panic(err)
	}
	fmt.Println(put1)

}
